using System;
using UnityEngine;

public class UIInitMatPlayer : MonoBehaviour
{
    [Header("需要改变的属性引用名")] [SerializeField]
    private string propName;

    [Header("最大时间")] [SerializeField] private float maxTime;
    private float _curTime;

    [Header("材质引用")] [SerializeField] private Material material;


    private void OnEnable()
    {
        _curTime = 0;
    }

    private void Update()
    {
        if (_curTime < maxTime)
        {
            _curTime += Time.deltaTime;
            material.SetFloat(propName, _curTime / maxTime);
        }
    }

    public Material GetMaterial()
    {
        return material;
    }
    
    public string GetPropName()
    {
        return propName;
    }
}
